package com.juc.threadpool;

/**
 * @author mobai
 * @since 2021/3/3 15:41
 */
public class ThreadStopTest {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> new Stop().run());
        thread.start();
        Thread.sleep(500);
        thread.interrupt();
//        System.out.println("我是主线程");


    }

    static  class Stop{

        public void run(){
            while (!Thread.currentThread().isInterrupted()){
                System.out.println("我是异步线程，我正在执行");
            }

        }

    }

    private ThreadStopTest(){}
}
